package com.cjj.common.enums;

/**
 * 二手商品分类枚举
 */
public enum ProductCategory {
    BOOKS("二手书籍"),
    STUDY_SUPPLIES("学习用品"),
    ELECTRONICS("电子产品");

    private final String value;

    ProductCategory(String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    /**
     * 通过值查找枚举
     */
    public static ProductCategory fromValue(String value) {
        for (ProductCategory category : values()) {
            if (category.getValue().equals(value)) {
                return category;
            }
        }
        throw new IllegalArgumentException("未知的商品分类: " + value);
    }

    /**
     * 获取所有可选值
     */
    public static String[] getAllValues() {
        ProductCategory[] categories = values();
        String[] values = new String[categories.length];
        for (int i = 0; i < categories.length; i++) {
            values[i] = categories[i].getValue();
        }
        return values;
    }

    @Override
    public String toString() {
        return value;
    }
}